<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>中兴商城ZTEmall.com_中兴手机Axon30 Pro、Axon30 Ultra、努比亚红魔6Pro、中兴路由器、中兴智能家居、官网正品保障</title>
    <link rel="stylesheet" href="../css/reset.css">
    <link rel="stylesheet" href="../css/login.css">
    <script src="../js/jquery-1.10.1.min.js"></script>
    <script src="../js/cookie.js"></script>
    <script src="../js/promise_ajax1.js"></script>
    <script src="../js/code.js"></script>
    <link rel="stylesheet" href="http://at.alicdn.com/t/font_2841806_tgc0ntb0k.css">
</head>
<style>
    #createCode {
        user-select: none;
    }
</style>

<body>
    <!-- 头部logo -->
    <div class="header">
        <div class="header-lg w cl">
            <a href="../html/index-ZTE.html">
                <img src="../images/logo.png" alt="">
            </a>
        </div>
    </div>
    <!-- 登陆区 -->
    <div class="main">
        <div class="main-lg w cl">
            <div class="left-photo">
                <img src="https://image.ztemall.com/2873fd16944282b200fd77a9790d0f12.png" width="500px"
                    style="margin: 30px 60px 0;" alt="">
            </div>
            <div class="right-login">
                <div class="login-header">
                    <div class="login-type"><span>会员登录 &nbsp;|&emsp;</span><span>短信登录
                            &nbsp;|&emsp;</span><span>员工登录</span>
                    </div>
                    <div class="go-register"><a href="../html/register-ZTE.html">免费注册></a></div>
                </div>
                <!-- 表单 -->
                <div class="login-box">
                    <form onsubmit="return false">
                        <input type="text" class="phoneInp" name="account" id="" value="" placeholder="会员帐号" required=""
                            data-caution="请填写登录帐号" autofocus="autofocus">
                        <!-- <div class="phoneSpan hint-con"></div> -->

                        <input type="password" class="pwdInp" name="password" id="" placeholder="填写密码" required=""
                            data-caution="请填写密码">
                        <!-- <div class="pwdSpan hint-con"></div> -->

                        <input type="text" class="codeInp" placeholder="验证码" name="verifycode" id="iptlogin" required=""
                            size="4" maxlength="4">
                        <span class="createCode">a1b2</span>
                        <span class="code_span">看不清？换一张</span>
                        <div class="codeSpan hint-con"></div>

                        <label><input type="checkbox" class="isRem"> 是否记住账号？</label>
                        <div class="forgetPwd">忘记密码？</div>

                        <button type="submit" class="loginBtn">登录</button>
                    </form>
                </div>
                <div class="login-bottom">
                    <a href=""><img src="https://res.ztemall.com/app/sysuser/statics/images/login/weibo.png" alt=""></a>
                    <a href=""><img src="https://res.ztemall.com/app/sysuser/statics/images/login/qq.png" alt=""></a>
                    <a href=""><img src="https://res.ztemall.com/app/sysuser/statics/images/login/weixin.png"
                            alt=""></a>
                </div>
            </div>
        </div>
    </div>
    <!-- 底部导航与版权 -->
    <div class="footer">
        <div style="text-align: center;">
            <img src="https://image.ztemall.com/4838cc505d2a981c5ae09c56958d8895.png">
        </div>
        <div class="footer-text" style="text-align: center;">增值电信业务经营许可证:
            <span>合字B2-20210066</span> | ICP备案证书号:<span>粤ICP备16018970号 | 粤公网安备 44030502005102号| 营业执照</span>
            <img src="https://szcert.ebs.org.cn/Images/govIcon.gif" alt="">
        </div>
    </div>
</body>
<script>
    $(".createCode").text(randCode());
    $(".createCode").click(function () {
        $(".createCode").text(randCode());
    })

    $(".loginBtn").click(function () {
        var phone = $(".phoneInp").val();
        var pwd = $(".pwdInp").val();
        var code = $(".codeInp").val();

        if (phone && pwd && code) {

            login({ phone, pwd }).then(result => {
                var { status, msg, phone } = result;
                if (status) {
                    if ($(".isRem").checked) {
                        setCookie("lgc", phone, 31);
                    } else {
                        setCookie("lgc", phone);
                    }

                    var url = urlParse();
                    if (url.returnUrl) {
                        location.href = decodeURIComponent(url.returnUrl);
                    } else {
                        location.href = "./index-ZTE.html";
                    }

                } else {
                    alert(msg);
                }
            }).catch(err => {
                throw err;
            })
        } else {
            alert("请输入完整信息");
        }
    })


    // 验证码验证
    var isCodeOk = false;
    $(".codeInp").blur(function () {
        isCodeOk = false;
        var code = $(".codeInp").val().trim();
        $(".codeInp").val(code);

        var RCode = $(".createCode").text();   //随机的验证码
        var codeReg = new RegExp(`^${RCode}$`, "i");

        if (codeReg.test(code)) {
            isCodeOk = true;
        } else {
            $(".codeSpan").text("* 验证码有误");
        }
    })

    // 数据解析
    function urlParse() {
        var search = location.search;
        var data = {};
        if (search) {
            // console.log(search);
            var str = search.substr(1);
            var list = str.split("&");
            // console.log(list);
            for (var i = 0; i < list.length; i++) {
                var item = list[i];
                var key = item.split("=")[0];
                var val = item.split("=")[1];
                data[key] = val;
            }
            // console.log(data);
        }
        return data;
    }
</script>

</html>